package com.haoshuang.zhouzhoubang.ui.page.order.rework.refuse

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.ResponseBean
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class RefuseReworkViewModel : BaseViewModel() {

    /**
     * 拒绝返工
     */
    val masterRejectApplyReworkData = StatefulMutableLiveData<ResponseBean<Any>>()
    fun masterRejectApplyRework(
        order_id: String?,
        reject_reason: String,
        reject_reason_images: String
    ) = netRequest {
        start { masterRejectApplyReworkData.value = StateData.Loading }
        request { ApiRepo.masterRejectApplyRework(order_id, reject_reason, reject_reason_images) }
        success { masterRejectApplyReworkData.value = StateData.Success(it) }
        error { code, msg ->
            masterRejectApplyReworkData.value = StateData.Error(code, msg)
        }
    }

}